package xin.common.http.response;

import org.springframework.data.domain.Page;

/**
 * <pre>
 * Page Wrapper
 * </pre>
 *
 * @author lixin_ma@outlook.com
 * @version 1.0
 * @since 2018/7/28 20:29
 */
public class PageWrapper {

    public static PageResponse wrap(Page page){
        PageResponse response = new PageResponse();
        response.setData(page.getContent());
        response.setSuccess(Boolean.TRUE);
        response.setTotalPages(page.getTotalPages());
        response.setTotalElements(page.getTotalElements());
        response.setPageNumber(page.getNumber() + 1);
        response.setPageSize(page.getSize());
        return response;
    }
}
